﻿SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON

GO


CREATE PROCEDURE [dbo].[bhp_temp_ModBlogStructure]
AS
BEGIN

	DECLARE
		@SettingsGroupId		INT
		
	SELECT @SettingsGroupId = id FROM n_Tree WHERE name = 'BLOG_SETTINGS' AND parent = 0
	
	
	EXEC [dbo].[n_ColFAdd] @rel = @SettingsGroupId, @name = N'similar_post_use_system', @typ = 5, @siz1 = 3, @siz2 = 1, @user = 900900
	INSERT INTO bht_Columns (ColumnId, DisplayName, [Description], Sort)
    SELECT
        id, N'Używać systemu podobnych postów?', N'', 100
    FROM
        n_Tree t
    WHERE
        parent = @SettingsGroupId
        AND name = N'similar_post_use_system'
	ALTER TABLE dbo.BLOG_SETTINGS ADD CONSTRAINT
		DF_BLOG_SETTINGS_similar_post_use_system DEFAULT 1 FOR similar_post_use_system
	
	EXEC [dbo].[n_ColFAdd] @rel = @SettingsGroupId, @name = N'similar_post_count', @typ = 1, @siz1 = 3, @siz2 = 1, @user = 900900
	INSERT INTO bht_Columns (ColumnId, DisplayName, [Description], Sort)
    SELECT
        id, N'Liczba postów', N'', 200
    FROM
        n_Tree t
    WHERE
        parent = @SettingsGroupId
        AND name = N'similar_post_count'
	ALTER TABLE dbo.BLOG_SETTINGS ADD CONSTRAINT
		DF_BLOG_SETTINGS_similar_post_count DEFAULT 3 FOR similar_post_count
		
		
	EXEC [dbo].[n_ColFAdd] @rel = @SettingsGroupId, @name = N'similar_post_dayago', @typ = 1, @siz1 = 3, @siz2 = 1, @user = 900900
	INSERT INTO bht_Columns (ColumnId, DisplayName, [Description], Sort)
    SELECT
        id, N'Dni do tyłu', N'Określa maksymalną liczbę dni do tyłu dla podobnych postów względem daty aktualnego posta', 300
    FROM
        n_Tree t
    WHERE
        parent = @SettingsGroupId
        AND name = N'similar_post_dayago'
	ALTER TABLE dbo.BLOG_SETTINGS ADD CONSTRAINT
		DF_BLOG_SETTINGS_similar_post_dayago DEFAULT 90 FOR similar_post_dayago
		
	EXEC [dbo].[n_ColFAdd] @rel = @SettingsGroupId, @name = N'similar_post_futuredays', @typ = 1, @siz1 = 3, @siz2 = 1, @user = 900900
	INSERT INTO bht_Columns (ColumnId, DisplayName, [Description], Sort)
    SELECT
        id, N'Dni do do przodu', N'Określa maksymalną liczbę dni do przodu dla podobnych postów względem daty aktualnego posta', 400
    FROM
        n_Tree t
    WHERE
        parent = @SettingsGroupId
        AND name = N'similar_post_futuredays'
	ALTER TABLE dbo.BLOG_SETTINGS ADD CONSTRAINT
		DF_BLOG_SETTINGS_similar_post_futuredays DEFAULT 90 FOR similar_post_futuredays
	
		
END
GO

EXEC [bhp_temp_ModBlogStructure]
GO

DROP PROCEDURE [bhp_temp_ModBlogStructure]